package com.md.infrastructure.persistence.repository;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.common.collect.Lists;
import com.md.base.BaseRepositoryImpl;
import com.md.domain.model.po.ModuleAppPO;
import com.md.domain.repository.ModuleAppRepository;
import com.md.infrastructure.persistence.mapper.ModuleAppMapper;
import com.md.util.ObjectUtil;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 刘骄阳
 * @date 2025/1/15 18:25
 **/
@Repository
public class DAOModuleAppRepository extends BaseRepositoryImpl<ModuleAppPO, ModuleAppMapper>
  implements ModuleAppRepository {

  public DAOModuleAppRepository(final ModuleAppMapper mapper) {
    super(mapper);
  }

  @Override
  public List<ModuleAppPO> queryModuleLinkByAppInfoIds(final Long moduleId, final List<Long> appInfoIds) {
    if (ObjectUtil.isEmpty(appInfoIds)) {
      return Lists.newArrayList();
    }
    LambdaQueryWrapper<ModuleAppPO> wrapper = new LambdaQueryWrapper<>();
    wrapper.eq(ModuleAppPO::getModuleId, moduleId).in(ModuleAppPO::getAppInfoId, appInfoIds);
    return mapper.selectList(wrapper);
  }

  @Override
  public List<ModuleAppPO> queryModuleLinkByModuleId(final Long moduleId) {
    LambdaQueryWrapper<ModuleAppPO> wrapper = new LambdaQueryWrapper<>();
    wrapper.eq(ModuleAppPO::getModuleId, moduleId);
    return mapper.selectList(wrapper);
  }
}
